<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>Document</title>
<link rel="stylesheet" href="../assets/agile/css/ratchet/css/ratchet.min.css">
<link rel="stylesheet" href="../assets/agile/css/flat/flat.component.css">
<link rel="stylesheet" href="../assets/agile/css/flat/iconline.css">
<link rel="stylesheet" href="../assets/app/css/app.css" />
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/local.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<style>body{background:#f5f5f5;}ul.listitem{background:#fff;}.listitem li{margin:5px auto 0px auto;}p.qm{overflow: hidden;white-space: nowrap;text-overflow:ellipsis;}.fx_list li span{width:33%;}</style>
</head>
<body>
<!--通用顶部-->
<div id="ios-top-box">
    <div id="header" class="bar bar-nav">
    <div class="titlebar">
    <a href="javascript:appClose('cashmanage',api);"><i class="iconfont iconline-arrow-left"></i></a>
    <h1 class="title">佣金管理</h1>
    </div>
    </div>
</div>
<!--通用顶部结束-->
<header class="bar bar-nav box_shadow head_a" style="margin-top:43px;">
	<a href="javascript:;" style="width:50%" class="selected_bottom">可用佣金</a>
	<a href="javascript:cashoutrecord();" style="width:50%">已提现佣金</a>
</header>
<section style="margin-top:95px !important;">
<div class="block10"></div>
<input type="hidden" value="0" name="enable_money" />
<div class="ke">可用佣金 <font class="enable_money">加载中...</font> 元</div>
<div class="block10"></div>
<div class="scroller create_goods">
<p style="text-align:center;padding:10px 0;display:none;">暂无数据</p>
</div>
<div class="clear"></div>
<button class="btn btn-positive btn-block login-btn reset-pwd-btn" style="width:50%;font-size:16px;display:none;"><a style="color:#fff;" href="javascript:;">全部转入账户</a></button>		
</section>
</body>
<script type="text/javascript">
function cashoutrecord(){
	if(!getUserinfo()){
		$.PageDialog.fail('请登录用户');
		return;
	}
	api.openWin({name:'agentcashoutrecord','url':'./agentcashoutrecord.html',reload:true});
}

apiready = function(){
	
	$(function(){
		$('.btn-positive').click(function(){
			if(!getUserinfo()){
				$.PageDialog.fail('请登录用户');
				return;
			}
			var enable_money = $('input[name=enable_money]').val();
			if(enable_money <= 0) api.alert({msg:'无佣金可用'});
			var userinfo = getUserinfo();
			GetJPData(config.url+'/app.php?act=intoaccount&uid='+userinfo.uid,{},function(data){
				if(data['status'] == 1){
					$('.enable_money').text(0);
					$('.btn-positive').hide();
					$('input[name=enable_money]').val(0);
					api.alert({msg:data['msg']},function(index,err){
						appClose('cashmanage',api);
						api.openWin({name:'userbalance','url':'./userbalance.html',reload:true});
					});
				}else{
					api.alert({msg:data['msg']});
				}
			});
		});
	});
	
	if(getUserinfo()){
		api.showProgress({title:'加载中',text:''});
		var userinfo = getUserinfo();
		GetJPData(config.url+'/app.php?act=cashmanage&uid='+userinfo.uid,{},function(data){
			api.hideProgress();
			
			if(data['status'] == 1){
				if(data['data'].length > 0){
					var html = '<ul class="fx_list">';
					html += '<li class="li_head"><span>年/月</span><span>销售总额</span><span class="noright">佣金总额</span></li>';
					for(var i in data['data']){
						html += '<li class="li_body">';
						html += '<span>'+data['data'][i]['time']+'</span>';
						html += '<span>￥'+data['data'][i]['count2']+'</span>';
						html += '<span>￥'+data['data'][i]['count']+'</span>';
						html += '</li>';
					}
					html += '</ul>';
					$('.scroller').html(html);
					$('.enable_money').text(data['enable_money']);
					if(data['enable_money'] != 0){
						$('.btn-positive').show();
						$('input[name=enable_money]').val(data['enable_money']);
					}
				}else{
					$('.btn-positive').hide();
					$('.scroller p').show();
					$('.enable_money').text(0);
				}
			}else{
				$('.scroller p').show();
				$('.btn-positive').hide();
				api.alert({msg:data['msg']});
				$('.enable_money').text(0);
			}
		});
	}else{
		$.PageDialog.fail('请登录用户');
	}
}
</script>
</html>